using System;
using System.Text;

namespace ctsu.Admin.BusLogic
{
	public class PatientInfo
	{
		private int _id = -1;
		private string _lastName = "";
		private string _firstName = "";
		private string _mrn = "";
		private string _otherID = "";
		private DateTime _dob = new DateTime(0);

		public PatientInfo()
		{
		}

		public int ID
		{
			get { return _id; }
			set { _id = value; }
		}
		public string LastName
		{
			get { return _lastName; }
			set { _lastName = value; }
		}
		public string FirstName
		{
			get { return _firstName; }
			set { _firstName = value; }
		}
		public string MRN
		{
			get { return _mrn; }
			set { _mrn = value; }
		}
		public string OtherID
		{
			get { return _otherID; }
			set { _otherID = value; }
		}
		public string Name
		{
			get
			{
				if (_firstName.Length == 0 && _lastName.Length == 0)
					return "";
				if (_firstName.Length == 0)
					return _lastName;
				if (_lastName.Length == 0)
					return _firstName;
				return _lastName + ", " + _firstName;
			}
		}
		public DateTime DateOfBirth
		{
			get { return _dob; }
			set { _dob = value; }
		}

		public string GetNameOrIdentifier()
		{
			if (_firstName.Length > 0 || _lastName.Length > 0)
			{
				if (_firstName.Length > 0 && _lastName.Length > 0)
					return _lastName + ", " + _firstName;
				if (_firstName.Length == 0)
					return _lastName;
				if (_lastName.Length == 0)
					return _firstName;
			}
			else if (_mrn.Length > 0)
				return _mrn;
			else return _otherID;
			return "";
		}

		public string GetMrnOrOtherIdentifier()
		{
			if (_mrn.Length > 0)
				return _mrn;
			else return _otherID;
		}

		public string GetToolTip()
		{
			StringBuilder sb = new StringBuilder();
			//add tooltip			
			sb.Append("Patient Information");
			sb.Append(Environment.NewLine);
			sb.Append("  Patient ID: " + ID);
			sb.Append(Environment.NewLine);
			sb.Append("  Patient: " + GetNameOrIdentifier());
			sb.Append(Environment.NewLine);
			if (MRN.Length > 0)
				sb.Append("  Patient MRN: " + MRN);
			else
				sb.Append("  Patient Other ID: " + OtherID);
			return sb.ToString();
		}

	}
}
